package com.home.service;


import com.home.entity.Position;
import com.home.mapper.PositionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class PositionService {
    @Autowired
    private PositionMapper positionMapper;

    public List<Position> getAllPosition() {
        List<Position> positions = positionMapper.getAllPosition();
        return positions;
    }

    public Integer addPosition(Position position) {
        position.setEnabled(true);
        position.setCreatedate(new Date());
        int insert = positionMapper.insertSelective(position);
        return insert;
    }

    public Integer deletePositionById(Integer id) {
        return positionMapper.deleteByPrimaryKey(id);
    }

    public Integer deletePositionsByIds(Integer[] ids) {
        return positionMapper.deletePositionsByIds(ids);
    }

    public Integer updateposition(Position position) {
        return positionMapper.updateByPrimaryKeySelective(position);
    }
}
